home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / sun / volume1 / calctool / part01 next >
Encoding:
Internet Message Format  |  1989-06-29  |  54.5 KB

  1. Path: uunet!dino!sharkey!mailrus!iuvax!rutgers!aramis.rutgers.edu!dartagnan.rutgers.edu!mcgrew
  2. From: mcgrew@dartagnan.rutgers.edu (Charles Mcgrew)
  3. Newsgroups: comp.sources.sun
  4. Subject: v01i038:  Calctool, a calculator for your Sun, Part01/02
  5. Message-ID: <Jun.29.22.13.35.1989.12581@dartagnan.rutgers.edu>
  6. Date: 30 Jun 89 02:13:38 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 1332
  9. Approved: mcgrew@aramis.rutgers.edu
  10.  
  11. Submitted-by: chuck@melmac.harris-atd.com (Chuck Musciano)
  12. Posting-number: Volume 1, Issue 38
  13. Archive-name: calctool/part01
  14.  
  15. #! /bin/sh
  16. # This is a shell archive, meaning:
  17. # 1. Remove everything above the #! /bin/sh line.
  18. # 2. Save the resulting text in a file.
  19. # 3. Execute the file with /bin/sh (not csh) to create the files:
  20. #    README
  21. #    Makefile
  22. #    calc.b.14.uu
  23. #    calc.r.7.uu
  24. #    calc.icon
  25. #    calctool.man
  26. #    display.c
  27. #    globals.c
  28. #    globals.h
  29. # This archive created: Thu Jun 29 21:58:20 1989
  30. export PATH; PATH=/bin:$PATH
  31. echo shar: extracting "'README'" '(1133 characters)'
  32. if test -f 'README'
  33. then
  34.     echo shar: will not over-write existing file "'README'"
  35. else
  36. sed 's/^    X//' << \SHAR_EOF > 'README'
  37.     XCalctool -- A scientific/programmer's calculator for Sun workstations
  38.     X
  39.     X     Calctool is a windowed calculator suitable for Suns running SunOS
  40.     X3.0 or higher, utilizing SunWindows and SunTools.  The code is relatively
  41.     Xstraightforward, and requires minimal modification to compile on most any
  42.     XSun system.
  43.     X
  44.     X     A glance at the Makefile will show that you should make sure that FONTDIR,
  45.     XBINDIR, MANDIR, and MANEXT are correct for your site before making calctool.
  46.     X
  47.     X     Calctool needs the font /usr/lib/fonts/fixedwidthfonts/gallant.r.19,
  48.     Xso make sure that this font exists.
  49.     X
  50.     X     The man page should explain most things.  Calctool is loosely based upon
  51.     XTI-type calculators, and uses an "Inverse" key to switch to alternate key
  52.     Xfunctions.  Calctool allows alternate functions to be reached directly by
  53.     Xselecting keys with the middle mouse button, rather than the left mouse button.
  54.     XRead the man page for more details.
  55.     X
  56.     X     Enjoy, and please send any bugs or comments to
  57.     X
  58.     X    Chuck Musciano
  59.     X    Advanced Technology Department
  60.     X    Harris Corporation
  61.     X    PO Box 37, MS 3A/1912
  62.     X    Melbourne, FL 32902
  63.     X
  64.     X    (305) 727-6131
  65.     X    ARPA: chuck@trantor.harris-atd.com
  66. SHAR_EOF
  67. if test 1133 -ne "`wc -c < 'README'`"
  68. then
  69.     echo shar: error transmitting "'README'" '(should have been 1133 characters)'
  70. fi
  71. fi # end of overwriting check
  72. echo shar: extracting "'Makefile'" '(1039 characters)'
  73. if test -f 'Makefile'
  74. then
  75.     echo shar: will not over-write existing file "'Makefile'"
  76. else
  77. sed 's/^    X//' << \SHAR_EOF > 'Makefile'
  78.     X# where you keep local fonts, if any
  79.     XFONTDIR        = .
  80.     X
  81.     X# where you keep local executables
  82.     XBINDIR        = /usr/local/bin
  83.     X
  84.     X# man directory for local man pages (usually /usr/man/manl)
  85.     XMANDIR        = /usr/man/manl
  86.     XMANEXT        = l
  87.     X
  88.     XOFILES        = display.o globals.o memory.o ops.o screen.o
  89.     XFONTS        = $(FONTDIR)/calc.b.14 $(FONTDIR)/calc.r.7
  90.     X
  91.     XWINDOW_LIB    = -lsuntool -lsunwindow -lpixrect
  92.     XMATH        = -lm
  93.     X
  94.     X.c.o:
  95.     X    cc -O -c -DKEY_FONT=\"$(FONTDIR)/calc.b.14\" -DSTATUS_FONT=\"$(FONTDIR)/calc.r.7\" $*.c
  96.     X
  97.     Xcalctool: $(FONTS) $(OFILES)
  98.     X    cc -o calctool $(OFILES) $(WINDOW_LIB) $(MATH)
  99.     X
  100.     X$(FONTDIR)/calc.b.14: calc.b.14.uu
  101.     X    uudecode < calc.b.14.uu
  102.     X    mv temp $(FONTDIR)/calc.b.14
  103.     X
  104.     X$(FONTDIR)/calc.r.7: calc.r.7.uu
  105.     X    uudecode < calc.r.7.uu
  106.     X    mv temp $(FONTDIR)/calc.r.7
  107.     X
  108.     Xinstall: calctool
  109.     X    cp calctool $(BINDIR)
  110.     X    cp calctool.man $(MANDIR)/calctool.$(MANEXT)
  111.     X
  112.     Xclean:
  113.     X    rm *.o core 
  114.     X
  115.     X# dependencies
  116.     X
  117.     Xdisplay.o: manifest.h globals.h keys.h
  118.     X
  119.     Xglobals.o: manifest.h globals.h
  120.     X
  121.     Xmemory.o: manifest.h globals.h
  122.     X
  123.     Xops.o: manifest.h globals.h keys.h
  124.     X
  125.     Xscreen.o: manifest.h globals.h keys.h calc.icon
  126. SHAR_EOF
  127. if test 1039 -ne "`wc -c < 'Makefile'`"
  128. then
  129.     echo shar: error transmitting "'Makefile'" '(should have been 1039 characters)'
  130. fi
  131. fi # end of overwriting check
  132. echo shar: extracting "'calc.b.14.uu'" '(10805 characters)'
  133. if test -f 'calc.b.14.uu'
  134. then
  135.     echo shar: will not over-write existing file "'calc.b.14.uu'"
  136. else
  137. sed 's/^    X//' << \SHAR_EOF > 'calc.b.14.uu'
  138.     Xbegin 644 temp
  139.     XM 1X4B  ) !(      "0-!0 )  D )  D#04 "0 ) $@ ) T%  D "0!L "0-
  140.     XM!0 )  D D  D#04 "0 ) +0 ) T%  D "0#8 "0-!0 )  D _  D#04 "0 )
  141.     XM 2  ) T%  D "0%$ "0-!0 )  D!:  D#04 "0 ) 8P ) T%  D "0&P "0-
  142.     XM!0 )  D!U  D#04 "0 ) ?@ ) T%  D "0(< "0-!0 )  D"0  D#04 "0 )
  143.     XM F0 ) T%  D "0*( "0-!0 )  D"K  D#04 "0 ) M  ) T%  D "0+T "0-
  144.     XM!0 )  D#&  D#04 "0 ) SP ) T%  D "0-@ "0-!0 )  D#A  D#04 "0 )
  145.     XM Z@ ) T%  D "0/, "0-!0 )  D#\  D#04 "0 )!!0 ) T%  D "00X "0-
  146.     XM!0 )  D$7  D#04 "0 )!(  ) T%  D "02D "0-!0 )  D$R  D#04 "0 )
  147.     XM!.P ) T%  D "040 "0-!0 )  D%-  D#04 "0 )!5@ ) T%  D "05\ "0-
  148.     XM!0 )  D%H  D#04 "0 )!<0 ) T%  D "07H "0-!0 )  D&#  D#04 "0 )
  149.     XM!C  ) T%  D "094 "0-!0 )  D&>  D#04 "0 )!IP ) T%  D "0;  "0-
  150.     XM!0 )  D&Y  D#04 "0 )!P@ ) T%  D "0<L "0-!0 )  D'4  D#04 "0 )
  151.     XM!W0 ) T%  D "0>8 "0-!0 )  D'O  D#04 "0 )!^  ) T%  D "0@$ "0-
  152.     XM!0 )  D(*  D#04 "0 )"$P ) T%  D "0AP "0-!0 )  D(E  D#04 "0 )
  153.     XM"+@ ) T%  D "0C< "0-!0 )  D)   D#04 "0 )"20 ) T%  D "0E( "0-
  154.     XM!0 )  D);  D#04 "0 )"9  ) T%  D "0FT "0-!0 )  D)V  D#04 "0 )
  155.     XM"?P ) T%  D "0H@ "0-!0 )  D*1  D#04 "0 )"F@ ) T%  D "0J, "0-
  156.     XM!0 )  D*L  D#04 "0 )"M0 ) T%  D "0KX "0-!0 )  D+'  D#04 "0 )
  157.     XM"T  ) T%  D "0MD "0-!0 )  D+B  D#04 "0 )"ZP ) T%  D "0O0 "0-
  158.     XM!0 )  D+]  D#04 "0 )#!@ ) T%  D "0P\ "0-!0 )  D,8  D#04 "0 )
  159.     XM#(0 ) T%  D "0RH "0-!0 )  D,S  D#04 "0 )#/  ) T%  D "0T4 "0-
  160.     XM!0 )  D-.  D#04 "0 )#5P ) T%  D "0V  "0-!0 )  D-I  D#04 "0 )
  161.     XM#<@ ) T%  D "0WL "0-!0 )  D.$  D#04 "0 )#C0 ) T%  D "0Y8 "0-
  162.     XM!0 )  D.?  D#04 "0 )#J  ) T%  D "0[$ "0-!0 )  D.Z  D#04 "0 )
  163.     XM#PP ) T%  D "0\P "0-!0 )  D/5  D#04 "0 )#W@ ) T%  D "0^< "0-
  164.     XM!0 )  D/P  D#04 "0 )#^0 ) T%  D "1 ( "0-!0 )  D0+  D#04 "0 )
  165.     XM$%  ) T%  D "1!T "0-!0 )  D0F  D#04 "0 )$+P ) T%  D "1#@ "0-
  166.     XM!0 )  D1!  D#04 "0 )$2@ ) T%  D "1%, "0-!0 )  D1<  D#04 "0 )
  167.     XM$90 ) T%  D "1&X "0-!0 )  D1W  D#04 "0 )$@  ) T%  D "1(D "0-
  168.     XM!0 )  D22  D#04 "0 )$FP ) T%  D "1*0 "0-!0 )  D2M  D#04 "0 )
  169.     XM$M@ ) T%  D "1+\ "0-!0 )  D3(  D#04 "0 )$T0 ) T%  D "1-H "0-
  170.     XM!0 )  D3C  D#04 "0 )$[  ) T%  D "1/4 "0-!0 )  D3^  D#04 "0 )
  171.     XM%!P ) T%  D "11  "0-!0 )  D49  D#04 "0 )                    
  172.     XM                                                            
  173.     XM                                                            
  174.     XM                                                            
  175.     XM                                                            
  176.     XM                                                            
  177.     XM                                                            
  178.     XM                                                            
  179.     XM                                                            
  180.     XM                                                            
  181.     XM                                                            
  182.     XM                                                            
  183.     XM                                                            
  184.     XM                                                            
  185.     XM                                                            
  186.     XM                                                            
  187.     XM                                                            
  188.     XM                                                            
  189.     XM                                                            
  190.     XM                                                            
  191.     XM                                                            
  192.     XM                                                            
  193.     XM                                                            
  194.     XM                                                            
  195.     XM                                                            
  196.     XM                                                         #@ 
  197.     XM.  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .    #@ .  X #@ .  X
  198.     XM #@ .  X #@ .  X #@ .  X #@ .    #@ .  X #@ .  X #@ .  X #@ 
  199.     XM.  X #@ .  X #@ .    #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X
  200.     XM #@ .    #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .       
  201.     XM                                                            
  202.     XM                                                            
  203.     XM                  #\ 'X _ !^ /P ?@#\ 'X _ !^ /P ?@#\ 'X _ !^
  204.     XM /P ?@#^ /X _@#^ /X _@#^ /X _@#^ /X _@#^ /X _@#^ /X _@ X #@ 
  205.     XM.  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X
  206.     XM #@ .  X #@ .  X #@ .  X #@ .                               
  207.     XM                                                            
  208.     XM                                                            
  209.     XM                                                            
  210.     XM                                                            
  211.     XM                                                            
  212.     XM                                                            
  213.     XM                                                            
  214.     XM                                                            
  215.     XM                     #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X
  216.     XM #@ .    #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .    #@ 
  217.     XM.  X #@ .  X #@ .  X #@ .  X #@ .  X #@ .    #@ .  X #@ .  X
  218.     XM #@ .  X #@ .  X #@ .  X #@ .    #@ .  X #@ .  X #@ .  X #@ 
  219.     XM.  X #@ .  X #@ .    #@ .  X #@ .  X #@ .  X #@ .  X #@ .  X
  220.     XM #@ .                                                    'X 
  221.     XM_ !^ /P ?@#\ 'X _ !^ /P ?@#\ 'X _ !^ /P ?@                  
  222.     XM                                         !@ &  8 !@ &  8 !@ 
  223.     XM   8 !@                      #8 -@ V #8                     
  224.     XM                 !L &P ; '^ -@ V /\ ; !L &P                 
  225.     XM   ( #X :P!K &L .  . &L :P!K #X "                    '8 E@"<
  226.     XM .P &  8 #< .0!I &X                      #@ ; !L #@ , ![ -X 
  227.     XMS #< '<                       P #  8 #                      
  228.     XM               &  P &  8 #  ,  P #  ,  8 !@ #  &            
  229.     XM   P !@ #  ,  8 !@ &  8 !@ ,  P &  P                    & !:
  230.     XM 'X / !^ %H &                               &  8 !@ _P#_ !@ 
  231.     XM&  8                                               8 !@ "  0
  232.     XM "                          ?P!_                            
  233.     XM                           8 !@                    #  8 !@ ,
  234.     XM  P &  8 #  , !@ &  P                    #X 8P!G &< :P!K ', 
  235.     XM<P!C #X                       P '  \  P #  ,  P #  , #\     
  236.     XM                 #X 8P!C  , !@ , !@ , !A '\                 
  237.     XM     #X 8P!C  , '@ '  , 8P!C #X                       ( !@ .
  238.     XM !X -@!F ,8 _P &  8                      '\ 8 !@ 'X  P #  , 
  239.     XM8P!C #X                      #X 8P!@ &  ?@!C &, 8P!C #X     
  240.     XM                 '\ 0P!#  8 !@ ,  P &  8 !@                 
  241.     XM     #X 8P!C &, /@!C &, 8P!C #X                      #X 8P!C
  242.     XM &, 8P _  ,  P!C #X                              !@ &       
  243.     XM   8 !@                              !@ &          8 !@ "  0
  244.     XM "             #  8 #  8 #  8  P !@ #  &  ,                 
  245.     XM          !_ '\      '\ ?P                        !@ #  &  ,
  246.     XM  8  P &  P &  P &                       #X 8P!C  , !@ ,  P 
  247.     XM   ,  P                      !P -@!C &\ :P!K &X 8  S !X     
  248.     XM                  @ '  < #8 -@ V &, ?P!C &,                 
  249.     XM     'P 9@!F &8 ? !F &, 8P!C 'X                      #X 8P!C
  250.     XM &  8 !@ &  8P!C #X                      'P 9@!C &, 8P!C &, 
  251.     XM8P!F 'P                      '\ 8 !@ &  ?@!@ &  8 !@ '\     
  252.     XM                 '\ 8 !@ &  ?@!@ &  8 !@ &                  
  253.     XM     #X 8P!C &  8 !G &, 8P!G #T                      &, 8P!C
  254.     XM &, ?P!C &, 8P!C &,                      'X &  8 !@ &  8 !@ 
  255.     XM&  8 'X                      !\ !@ &  8 !@ &  8 9@!F #P     
  256.     XM                 &, 9@!L '@ ? !L &8 9@!C &,                 
  257.     XM     &  8 !@ &  8 !@ &  8 !@ '\                      ,, PP#G
  258.     XM .< _P#; -L PP## ,,                      &, 8P!S ', >P!K &\ 
  259.     XM9P!G &,                      #X 8P!C &, 8P!C &, 8P!C #X     
  260.     XM                 'X 8P!C &, 8P!^ &  8 !@ &                  
  261.     XM     #X 8P!C &, 8P!C &, 8P!C #X &  ,  <              'X 8P!C
  262.     XM &, ?@!L &8 9@!C &,                      #X 8P!C #  '  &  , 
  263.     XM8P!C #X                      /\ &  8 !@ &  8 !@ &  8 !@     
  264.     XM                 &, 8P!C &, 8P!C &, 8P!C #X                 
  265.     XM     &, 8P!C #8 -@ V !P '  (  @                      ,& R8#)
  266.     XM@-V 70!W '< -@ B "(                      &, 8P V #8 '  < #8 
  267.     XM-@!C &,                      ,, PP!F &8 /  8 !@ &  8 !@     
  268.     XM                 '\  P #  8 #  8 #  8 !@ '\                 
  269.     XM   ^ #  ,  P #  ,  P #  ,  P #  ,  ^              #  &  8  P
  270.     XM #  &  8  P #  &  8  P                 ^  8 !@ &  8 !@ &  8 
  271.     XM!@ &  8 !@ ^                  @ '  V &,                     
  272.     XM                                            _P#_            
  273.     XM     #  ,  8  P                                             
  274.     XM #P 9@ & #X 9@!F #\                      &  8 !@ &X <P!C &, 
  275.     XM8P!S &X                              #X 8P!@ &  8 !C #X     
  276.     XM                  ,  P # #L 9P!C &, 8P!G #L                 
  277.     XM             #X 8P!C '\ 8 !C #X                       X &P 8
  278.     XM !@ ?@ 8 !@ &  8 !@                              #L 9P!C &, 
  279.     XM8P!G #L  P!C #X              &  8 !@ &X <P!C &, 8P!C &,     
  280.     XM                  P #    #P #  ,  P #  ,  P                 
  281.     XM      8 !@   !X !@ &  8 !@ &  8 !@!F #P              &  8 !@
  282.     XM &8 ; !X '@ ; !F &,                      #P #  ,  P #  ,  P 
  283.     XM#  ,  P                              +8 VP#; -L VP#; -L     
  284.     XM                         %X <P!C &, 8P!C &,                 
  285.     XM             #X 8P!C &, 8P!C #X                             
  286.     XM &X <P!C &, 8P!S &X 8 !@ &  8                    #L 9P!C &, 
  287.     XM8P!G #L  P #  ,  P                   &X >P!@ &  8 !@ &      
  288.     XM                         #X 8P!@ #X  P!C #X                 
  289.     XM     !@ &  8 'X &  8 !@ &  ;  X                             
  290.     XM &, 8P!C &, 8P!G #L                              &, 8P V #8 
  291.     XM'  <  @                              ,, PP#; -L VP#; 'X     
  292.     XM                         &8 9@ \ !@ / !F &8                 
  293.     XM             &, 8P S #8 %@ <  P # !( '@ ,                   
  294.     XM '\ !@ , !@ , !@ '\                    / !@ &  8 !@ & !P !@ 
  295.     XM&  8 !@ &  /               8 !@ &  8 !@ &    !@ &  8 !@ &  8
  296.     XM              !X  P #  ,  P #  '  P #  ,  P # !X            
  297.     XM        .P!_ &X                                   #P -@ V #P
  298.     XM -@ V     X &P ; !L &P .         &8 9@ \ !@ / !F &8         
  299.     XM                          #_ /\      &8 9@ \ !@ / !F &8     
  300.     XM                @ "  8 !@ ,  P!F &8 /  \ !@ &         !$ &P 
  301.     XM.  X@&R 18 !@ ,  P!F &8 /  \ !@ &                 #_@/^     
  302.     XM &, 8P S #8 %@ <  P # !( '@ ,     8 #@#F .8 !@ &  \         
  303.     XM                     #@ ;  , !@ , !@ 'P                     
  304.     XM                     0!_ /X 9@!F &8 9@!F &8               P 
  305.     XM'  ,  P #  , !X  ( !@ , !@ , !@ ,  @          , !@ , !@ , !@
  306.     XM ,  @  S #, '@ , !X ,P S         !@ &  8 /\ _P 8 !@ &( !@ , 
  307.     XM!@ , !@ , !@ $        , !@ , !@ , !@ ,  @    '\ ?P          
  308.     XM                    &  8    _P#_    &  8                    
  309.     XM   ? #\ < !@ &  8 !@ &0 9@!S #^ 'X #  8 !  0 #  8 #\ /X 9P S
  310.     XM !,  P #  ,  P ' 'X ?          $  8  P ?@#^ <P!F &0 8 !@ &  
  311.     XM8 !P #\ 'P                !\ 'X !P #  ,  P # !, ,P!G /X _ !@
  312.     XI #  $       #  ,  P ?X!_@ P #  ,         '^ ?X          
  313.     X 
  314.     Xend
  315. SHAR_EOF
  316. if test 10805 -ne "`wc -c < 'calc.b.14.uu'`"
  317. then
  318.     echo shar: error transmitting "'calc.b.14.uu'" '(should have been 10805 characters)'
  319. fi
  320. fi # end of overwriting check
  321. echo shar: extracting "'calc.r.7.uu'" '(5073 characters)'
  322. if test -f 'calc.r.7.uu'
  323. then
  324.     echo shar: will not over-write existing file "'calc.r.7.uu'"
  325. else
  326. sed 's/^    X//' << \SHAR_EOF > 'calc.r.7.uu'
  327.     Xbegin 644 temp
  328.     XM 1X$2  &  @       @& @ &  8 "  (!@( !@ & !  " 8"  8 !@ 8  @&
  329.     XM @ &  8 (  (!@( !@ & "@ " 8"  8 !@ P  @& @ &  8 .  (!@( !@ &
  330.     XM $  " 8"  8 !@!(  @& @ &  8 4  (!@( !@ & %@ " 8"  8 !@!@  @&
  331.     XM @ &  8 :  (!@( !@ & '  " 8"  8 !@!X  @& @ &  8 @  (!@( !@ &
  332.     XM (@ " 8"  8 !@"0  @& @ &  8 F  (!@( !@ & *  " 8"  8 !@"H  @&
  333.     XM @ &  8 L  (!@( !@ & +@ " 8"  8 !@#   @& @ &  8 R  (!@( !@ &
  334.     XM -  " 8"  8 !@#8  @& @ &  8 X  (!@( !@ & .@ " 8"  8 !@#P  @&
  335.     XM @ &  8 ^  (!@( !@ & 0  " 8"  8 !@$(  @& @ &  8!$  (!@( !@ &
  336.     XM 1@ " 8"  8 !@$@  @& @ &  8!*  (!@( !@ & 3  " 8"  8 !@$X  @&
  337.     XM @ &  8!0  (!@( !@ & 4@ " 8"  8 !@%0  @& @ &  8!6  (!@( !@ &
  338.     XM 6  " 8"  8 !@%H  @& @ &  8!<  (!@( !@ & 7@ " 8"  8 !@&   @&
  339.     XM @ &  8!B  (!@( !@ & 9  " 8"  8 !@&8  @& @ &  8!H  (!@( !@ &
  340.     XM :@ " 8"  8 !@&P  @& @ &  8!N  (!@( !@ & <  " 8"  8 !@'(  @&
  341.     XM @ &  8!T  (!@( !@ & =@ " 8"  8 !@'@  @& @ &  8!Z  (!@( !@ &
  342.     XM ?  " 8"  8 !@'X  @& @ &  8"   (!@( !@ & @@ " 8"  8 !@(0  @&
  343.     XM @ &  8"&  (!@( !@ & B  " 8"  8 !@(H  @& @ &  8",  (!@( !@ &
  344.     XM C@ " 8"  8 !@)   @& @ &  8"2  (!@( !@ & E  " 8"  8 !@)8  @&
  345.     XM @ &  8"8  (!@( !@ & F@ " 8"  8 !@)P  @& @ &  8">  (!@( !@ &
  346.     XM H  " 8"  8 !@*(  @& @ &  8"D  (!@( !@ & I@ " 8"  8 !@*@  @&
  347.     XM @ &  8"J  (!@( !@ & K  " 8"  8 !@*X  @& @ &  8"P  (!@( !@ &
  348.     XM L@ " 8"  8 !@+0  @& @ &  8"V  (!@( !@ & N  " 8"  8 !@+H  @&
  349.     XM @ &  8"\  (!@( !@ & O@ " 8"  8 !@,   @& @ &  8#"  (!@( !@ &
  350.     XM Q  " 8"  8 !@,8  @& @ &  8#(  (!@( !@ & R@ " 8"  8 !@,P  @&
  351.     XM @ &  8#.  (!@( !@ & T  " 8"  8 !@-(  @& @ &  8#4  (!@( !@ &
  352.     XM U@ " 8"  8 !@-@  @& @ &  8#:  (!@( !@ & W  " 8"  8 !@-X  @&
  353.     XM @ &  8#@  (!@( !@ & X@ " 8"  8 !@.0  @& @ &  8#F  (!@( !@ &
  354.     XM Z  " 8"  8 !@.H  @& @ &  8#L  (!@( !@ & [@ " 8"  8 !@/   @&
  355.     XM @ &  8#R  (!@( !@ & ]  " 8"  8 !@/8  @& @ &  8#X  (!@( !@ &
  356.     XM ^@ " 8"  8 !@/P  @& @ &  8#^  (!@( !@ &!   " 8"  8 !@0(  @&
  357.     XM @ &  8$$  (!@( !@ &!!@ " 8"  8 !@0@  @& @ &  8$*  (!@( !@ &
  358.     XM!#  " 8"  8 !@0X  @& @ &  8$0  (!@( !@ &                    
  359.     XM                                                            
  360.     XM                                                            
  361.     XM                                                            
  362.     XM                                                            
  363.     XM                                                            
  364.     XM                                                            
  365.     XM                                                            
  366.     XM                                                            
  367.     XM                                                            
  368.     XM                                                            
  369.     XM                                                            
  370.     XM                                                            
  371.     XM                                                            
  372.     XM                                                            
  373.     XM                                                            
  374.     XM                                                            
  375.     XM                                                            
  376.     XM                                                            
  377.     XM                                                            
  378.     XM                                                            
  379.     XM                                                            
  380.     XM                                                            
  381.     XM                                                            
  382.     XM                                                            
  383.     XM                                                            
  384.     XM                                                            
  385.     XM        ?$141'P  ! 0$%0X$      T2$@T   8)#@D)#@@   0*$0     
  386.     XM  !\! 0     '" X(!P   !\*"@H)   0" 0*$1$  "J5:I5JE6J5?______
  387.     XM____P,# P,# P, # P,# P,# SA 6%0X%!0  "A45%0H   P"!PD)!@    \
  388.     XM0$ \     '@$!'@    8)"0D)"0  "0D)"0D&   1$1\1"@0  !\!!P$!'P 
  389.     XM   X5&Q4.      H?"@           !\   0"'P($    "!4"      $"'P0
  390.     XM?"!    ($" 0"#P  ! (! @0/   ? !\ 'P   !$*!                 0
  391.     XM$! 0 !   "@H*       *'PH*'PH   0/% X%'@0 'QD"! L3   ,% @5$AT
  392.     XM   ("!       ! @0$! (!  (! (" @0(   5#AL.%0    0$'P0$       
  393.     XM ! 0(     !X           0$   "! 0("!    P2%AH2#   ! P$! 0.   
  394.     XM,$@(,$!X   P2! (2#   ! P4'@0$   >$!P"$@P   P0'!(2#   '@($! @
  395.     XM(   ,$@P2$@P   P2$@X"#     0$  0$    " @ " @0   "! @$ @     
  396.     XM> !X     " 0"! @   P2 @P "   #A$7%Q .   ,$A(>$A(  !P2'!(2'  
  397.     XM #!(0$!(,   <$A(2$AP  !X0'! 0'@  'A <$! 0   ,$A 6$@P  !(2'A(
  398.     XM2$@  #@0$! 0.   . @("$@P  !$2%!P2$0  $! 0$! >   1&Q45$1$  !$
  399.     XM9%1,1$0  #!(2$A(,   <$A(<$!    X1$143#@$ '!(2'!02   ,$@@$$@P
  400.     XM  !\$! 0$!   $A(2$A(,   1$1$*"@0  !$1%14;$0  $0H$"A$1   1$0X
  401.     XM$! 0  !X"! @0'@  #@@(" @(#@ 0" @$! (   X" @(" @X ! H1       
  402.     XM        >  0$ @        P"#A(*   0'!(2$AP    .$! 0#@   @X2$A(
  403.     XM.    #!(<$ X   8(' @("     X2$@X"'  0%!H2$A(   0 # 0$!   !  
  404.     XM,! 0$&  0$A08%!(   P$! 0$!    !H5%145    %!H2$A(    ,$A(2#  
  405.     XM  !0:$AH4$   "A82%@H"   4&A 0$     X0# (<   ('@@(" 8    2$A(
  406.     XM6"@   !$1"@H$    $1$5%0H    1"@0*$0   !(2$@X"'   '@($"!X   8
  407.     XM("! (" 8 ! 0$! 0$!  8! 0"! 08   (%0(     'Q\?'Q\?'P )$B0D$@D
  408.     XM  "02"0D2)   '"(B)R(8   .$1$Y$0(  !0Z$0$Z!     0 'P $   % @4
  409.     X5H*!@(,"@1*0(:"@0  #X %!0,!!@
  410.     X 
  411.     Xend
  412. SHAR_EOF
  413. if test 5073 -ne "`wc -c < 'calc.r.7.uu'`"
  414. then
  415.     echo shar: error transmitting "'calc.r.7.uu'" '(should have been 5073 characters)'
  416. fi
  417. fi # end of overwriting check
  418. echo shar: extracting "'calc.icon'" '(1485 characters)'
  419. if test -f 'calc.icon'
  420. then
  421.     echo shar: will not over-write existing file "'calc.icon'"
  422. else
  423. sed 's/^    X//' << \SHAR_EOF > 'calc.icon'
  424.     X/* Format_version=1, Width=48, Height=64, Depth=1, Valid_bits_per_item=16
  425.     X */
  426.     X    0xBFFF,0xFFFF,0xFFFA,0x6000,0x0000,0x000C,
  427.     X    0xC000,0x0000,0x0006,0x8000,0x0000,0x0002,
  428.     X    0x8FFF,0xFFFF,0xFFE2,0x8800,0x0000,0x0022,
  429.     X    0x884E,0xEAEE,0xEE22,0x8842,0x2A88,0x2A22,
  430.     X    0x884E,0x6EEE,0x2E22,0x8848,0x222A,0x2A22,
  431.     X    0x884E,0xE2EE,0x2E22,0x8800,0x0000,0x0022,
  432.     X    0x8FFF,0xFFFF,0xFFE2,0x8000,0x0000,0x0002,
  433.     X    0x8000,0x0000,0x0002,0x8000,0x0000,0x0002,
  434.     X    0x8FFB,0xFEFF,0xBFE2,0x880A,0x0280,0xA022,
  435.     X    0x89CA,0x729C,0xA8A2,0x884A,0x5294,0xA522,
  436.     X    0x884A,0x729C,0xA222,0x884A,0x5284,0xA522,
  437.     X    0x884A,0x729C,0xA8A2,0x880A,0x0280,0xA022,
  438.     X    0x8FFB,0xFEFF,0xBFE2,0x8000,0x0000,0x0002,
  439.     X    0x8000,0x0000,0x0002,0x8FFB,0xFEFF,0xBFE2,
  440.     X    0x880A,0x0280,0xA022,0x894A,0x729C,0xA222,
  441.     X    0x894A,0x4290,0xA022,0x89CA,0x729C,0xAFA2,
  442.     X    0x884A,0x1294,0xA022,0x884A,0x729C,0xA222,
  443.     X    0x880A,0x0280,0xA022,0x8FFB,0xFEFF,0xBFE2,
  444.     X    0x8000,0x0000,0x0002,0x8000,0x0000,0x0002,
  445.     X    0x8FFB,0xFEFF,0xBFE2,0x880A,0x0280,0xA022,
  446.     X    0x888A,0x729C,0xA222,0x888A,0x1284,0xA222,
  447.     X    0x888A,0x728C,0xAFA2,0x888A,0x4284,0xA222,
  448.     X    0x888A,0x729C,0xA222,0x880A,0x0280,0xA022,
  449.     X    0x8FFB,0xFEFF,0xBFE2,0x8000,0x0000,0x0002,
  450.     X    0x8000,0x0000,0x0002,0x8FFB,0xFEFF,0xBFE2,
  451.     X    0x880A,0x0280,0xA022,0x89CA,0x7280,0xA022,
  452.     X    0x890A,0x529C,0xA022,0x890A,0x5280,0xAFA2,
  453.     X    0x890A,0x529C,0xA022,0x89CA,0x7280,0xA022,
  454.     X    0x880A,0x0280,0xA022,0x8FFB,0xFEFF,0xBFE2,
  455.     X    0x8000,0x0000,0x0002,0x8000,0x0000,0x0002,
  456.     X    0x8000,0x0000,0x0002,0x4000,0x0000,0x0004,
  457.     X    0xA000,0x0000,0x000A,0x5FFF,0xFFFF,0xFFF4
  458. SHAR_EOF
  459. if test 1485 -ne "`wc -c < 'calc.icon'`"
  460. then
  461.     echo shar: error transmitting "'calc.icon'" '(should have been 1485 characters)'
  462. fi
  463. fi # end of overwriting check
  464. echo shar: extracting "'calctool.man'" '(7307 characters)'
  465. if test -f 'calctool.man'
  466. then
  467.     echo shar: will not over-write existing file "'calctool.man'"
  468. else
  469. sed 's/^    X//' << \SHAR_EOF > 'calctool.man'
  470.     X.TH CALCTOOL 1 "21 November 1986"
  471.     X.SH NAME
  472.     Xcalctool \- desktop calculator
  473.     X.SH SYNOPSIS
  474.     X\fBcalctool\fP
  475.     X.SH DESCRIPTION
  476.     X.LP
  477.     X\f2Calctool\fP is desktop calculator which runs under \f2suntools\fP(1).
  478.     XUsers interact with \f2calctool\fP using the mouse and keyboard as
  479.     Xdescribed below.  \f2Calctool\fP honors the standard window command line
  480.     Xoptions.
  481.     X.LP
  482.     X\f2Calctool\fP can be used as a scientific calculator, providing the
  483.     Xstandard trigonometric and transcendental functions, or it can be used as
  484.     Xa programmer's calculator, allowing bitwise manipulation of binary, octal,
  485.     Xand hexadecimal values.  All internal values in \f2calctool\fP are maintained
  486.     Xusing double  precision floating point.
  487.     X.SH "USER INTERFACE"
  488.     X.sp
  489.     X.SH "The Display"
  490.     X.LP
  491.     X\f2Calctool\fP presents the user with a keyboard and a display area.  The
  492.     Xdisplay area displays the results of calculations, and a status line 
  493.     Xshowing information about the current mode of \f2calctool\fP.  The left portion
  494.     Xof the status line displays the operator stack, allowing the user to track
  495.     Xpending operations as \f2calctool\fP stacks them.  The middle of the display
  496.     Xline shows the current trigonometric mode, either \*(lqDeg\*(rq, \*(lqRad\*(rq,
  497.     Xor \*(lqGrad\*(rq.  To the right of the trigonometric mode, either \*(lqEE\*(rq
  498.     Xor \*(lqEng\*(rq will appear when the calculator is in scientific exponential
  499.     Xor engineering exponential mode.  The right portion shows the current display precision,
  500.     Xindicating the number of decimal digits shown (in scientific mode) or the
  501.     Xnumber of bits shown (in programmer mode).
  502.     X.LP
  503.     XIn scientific or enigneering mode, the value in the display is presented in fixed point notation if it
  504.     Xis small enough, or is converted to scientific notation if not.  In programmer
  505.     Xmode, the value is presented as a bit string in the appropriate base. The
  506.     X\f3Fix\fP and \f3EE\fP keys, below, control the precision and format of the display.
  507.     X.SH "The Keyboard"
  508.     X.LP
  509.     XThe various keys on the keyboard are, for the most part, self-explanatory.
  510.     XKeys are \*(lqpressed\*(rq by clicking the left mouse button on the key.
  511.     XSome keys also have inverted functions, which are accessed by first
  512.     Xclicking the \f3Inverse\fP key, and then clicking the desired inverse
  513.     Xfunction.  Clicking the \f3Inverse\fP key causes the inverse functions
  514.     Xto be displayed.  Those keys without inverse functions are grayed out.
  515.     X.LP
  516.     XA shortcut method is provided to access inverse functions.  Clicking the
  517.     Xmiddle button on a key accesses its inverse function directly, without
  518.     Xpressing the \f3Inverse\fP key first.  Pressing and holding the middle button
  519.     Xon a key will preview its inverse function; releasing the middle button
  520.     Xwill activate the inverse function.
  521.     X.LP
  522.     XSeveral keys on the keyboard have special functions associated with them.
  523.     XThese keys are:
  524.     X.IP "\f3Sto\fP, \f3Rcl\fP, \f3Exc\fP"
  525.     XWhen accessed with the left button, these keys access memory 0 of \f2calctool\fP.
  526.     XIf more memories are desired, they can be accessed by pressing the right
  527.     Xbutton on the desired key.  A menu will pop up, showing the various memories
  528.     Xcurrently in use.  In the case of the \f3Rcl\fP or \f3Exc\fP keys, selecting a memory
  529.     Xwill cause that memory to be recalled to, or exchanged with, the value in the
  530.     Xdisplay.  The \f3Sto\fP key works in a similar manner, except that an additional
  531.     Xentry, \*(lqNew Memory\*(rq, is also provided.  Selecting \*(lqNew Memory\*(rq
  532.     Xcauses a new memory to be created, containing the value in the display.  Up to
  533.     X42 memories (0 through 41) can be created in this manner.
  534.     X.IP "\f3Fix\fP, \f3DRG\fP"
  535.     XThe \f3Fix\fP key is visible in normal scientific or programmer mode, while the
  536.     X\f3DRG\fP key is visible in inverted scientific mode.  When accessed with the
  537.     Xleft and middle buttons, these keys cycle through the various display modes.
  538.     XIn scientific mode, the \f3Fix\fP key cycles through 0 to 12 digits, and floating,
  539.     Xprecision.  This value determines the number of digits which follow the decimal
  540.     Xpoint in the display.  In programmer mode, the \f3Fix\fP key cycles through
  541.     Xthe available bit widths, which for binary is 4, 8, or 16 bits, and for octal
  542.     Xand hexadecimal is 8, 16, or 32 bits.  The \f3DRG\fP key cycles among the
  543.     Xdegrees, radians, and grads trigonometric modes, which determines how the
  544.     Xtrigonometric functions will accept and display their arguments.
  545.     X.IP
  546.     XEither of these keys cycles when clicked with the left button, and displays a
  547.     Xmenu when clicked with the right button.
  548.     X.IP "\f3Scientific\fP, \f3Binary\fP, \f3Octal\fP, \f3Hexadecimal\fP"
  549.     XThis large key cycles between the various calculator modes.  Clicking with the
  550.     Xleft button cycles through the four modes, while the right button displays a
  551.     Xmenu of the various modes.  When switching from one mode to another, the
  552.     Xdisplay is modified to reflect the new mode.  The \f2internal value\fP of
  553.     Xthe display is not changed until that value is used.  For example, if the current
  554.     Xvalue in the display is \*(lq14.5\*(rq, selecting hexadecimal mode will cause the 
  555.     Xdisplay to read \*(lqD\*(rq.  However, the internal value is still 14.5.
  556.     XReturning to scientific mode will restore the display to \*(lq14.5\*(rq.  If,
  557.     Xwhile in hexadecimal mode, 1 was added to the display, (displaying \*(lqE\*(rq),
  558.     Xreturning to scientific mode would display \*(lq15\*(rq, since hexadecimal mode
  559.     Xtruncated the display before using it.
  560.     X.IP \f3EE\fP
  561.     XThis key places the calculator in exponential mode, which causes all results
  562.     Xto be displayed in scientific notation.  In scientific mode, normal
  563.     Xscientific notation is used.  In engineering mode, the exponent is
  564.     Xadjusted to a multiple of three.  To return to normal display mode,
  565.     Xclick \f3Inverse\fP \f3EE\fP.  This key also allows the user to enter
  566.     Xexponents when keying in a value.  Clicking \f3EE\fP once allows the user to
  567.     Xenter the exponent value.  Clicking again returns the user to entering the
  568.     Xmantissa.
  569.     X.IP "\f3Erase\fP, \f3Clear\fP"
  570.     XThe \f3Erase\fP key erases the currently displayed value and replaces it
  571.     Xwith zero.  The \f3Clear\fP key erases the display, the internal value stack,
  572.     Xand the internal operator stack.  The \f3Clear\fP key can be accessed by
  573.     Xclicking the \f3Erase\fP key with the middle mouse button.
  574.     X.SH "Typing Values"
  575.     X.LP
  576.     XInstead of clicking keys, the user can type values directly on the keyboard.
  577.     X\f2Calctool\fP will recognize the digits \*(lq0\*(rq through \*(lq9\*(rq, and \*(lqA\*(rq through \*(lqF\*(rq in
  578.     Xhexadecimal mode.  In scientific mode, the \*(lqE\*(rq key acts like the
  579.     X\f3EE\fP key
  580.     Xand the \*(lq.\*(rq key acts like the decimal point key.  
  581.     XThe \*(lq+\*(rq, \*(lq-\*(rq, \*(lq*\*(rq, and \*(lq/\*(rq keys correspond to addition, subtraction,
  582.     Xmultiplication, and division, and \*(lq(\*(rq, \*(lq)\*(rq, and \*(lq=\*(rq perform the expected function.
  583.     XIn addition, the \*(lqS\*(rq, \*(lqR\*(rq, and \*(lqG\*(rq keys correspond to the store, recall and 
  584.     Xexchange functions.  The \*(lqX\*(rq key is equivalent to \*(lq*\*(rq, and carriage return and newline 
  585.     Xact like the \*(lq=\*(rq key.
  586.     X.SH AUTHOR
  587.     X.LP
  588.     XChuck Musciano
  589.     X.br
  590.     XAdvanced Technology Department
  591.     X.br
  592.     XHarris Corporation
  593.     X.br
  594.     XPO Box 37, MS 3A/1912
  595.     X.br
  596.     XMelbourne, FL 32909
  597.     X.br
  598.     X(305) 727-6131
  599.     X.br
  600.     XARPA: chuck@trantor.harris-atd.com
  601.     X.SH BUGS
  602.     X.LP
  603.     XKeystrokes are ignored when the mouse is positioned in the \f3Scientific\fP
  604.     Xkey.
  605.     X.LP
  606.     XThere is no way to effect the \f3+/-\fP key from the keyboard.
  607. SHAR_EOF
  608. if test 7307 -ne "`wc -c < 'calctool.man'`"
  609. then
  610.     echo shar: error transmitting "'calctool.man'" '(should have been 7307 characters)'
  611. fi
  612. fi # end of overwriting check
  613. echo shar: extracting "'display.c'" '(19031 characters)'
  614. if test -f 'display.c'
  615. then
  616.     echo shar: will not over-write existing file "'display.c'"
  617. else
  618. sed 's/^    X//' << \SHAR_EOF > 'display.c'
  619.     X/************************************************************************/
  620.     X/*    Copyright 1988 by Chuck Musciano and Harris Corporation        */
  621.     X/*                                    */
  622.     X/*    Permission to use, copy, modify, and distribute this software    */
  623.     X/*    and its documentation for any purpose and without fee is    */
  624.     X/*    hereby granted, provided that the above copyright notice    */
  625.     X/*    appear in all copies and that both that copyright notice and    */
  626.     X/*    this permission notice appear in supporting documentation, and    */
  627.     X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  628.     X/*    used in advertising or publicity pertaining to distribution    */
  629.     X/*    of the software without specific, written prior permission.    */
  630.     X/*    Chuck Musciano and Harris Corporation make no representations    */
  631.     X/*    about the suitability of this software for any purpose.  It is    */
  632.     X/*    provided "as is" without express or implied warranty.        */
  633.     X/************************************************************************/
  634.     X
  635.     X/************************************************************************/
  636.     X/*                                    */
  637.     X/*    Module:        display.c                    */
  638.     X/*                                    */
  639.     X/*    Function:    Manage calculator display            */
  640.     X/*                                    */
  641.     X/*    Public Names:    update_display    resolve stack top and display    */
  642.     X/*            convert_display    convert user entry to stack top    */
  643.     X/*            convert_value    convert value to string        */
  644.     X/*            fix_proc    handle display widths        */
  645.     X/*            do_digit    handle digit input        */
  646.     X/*            clear_entry    clear any typed digits        */
  647.     X/*            keyboard    handle keyboard entries        */
  648.     X/*                                    */
  649.     X/*    Change History:    17 Nov 86    Creation            */
  650.     X/*                                    */
  651.     X/************************************************************************/
  652.     X
  653.     X#include    <stdio.h>
  654.     X
  655.     X#include    <suntool/sunview.h>
  656.     X#include    <suntool/panel.h>
  657.     X#include    <suntool/canvas.h>
  658.     X
  659.     X#include    "manifest.h"
  660.     X#include    "globals.h"
  661.     X#include    "keys.h"
  662.     X
  663.     X#define        DIGIT_FONT        "/usr/lib/fonts/fixedwidthfonts/gallant.r.19"
  664.     X
  665.     X#define        margin(x)        (((curr_mode == SCIENTIFIC? 15 : 16) - strlen(x)) * DIGIT_WIDTH)
  666.     X
  667.     X#define        MAX_DIGITS        ((curr_mode == SCIENTIFIC)? 14 : 16)
  668.     X#define        DIGIT_WIDTH        d_font->pf_defaultsize.x
  669.     X#define        DIGIT_HEIGHT        d_font->pf_defaultsize.y
  670.     X#define        STATUS_WIDTH        s_font->pf_defaultsize.x
  671.     X#define        STATUS_HEIGHT        s_font->pf_defaultsize.y
  672.     X
  673.     XPUBLIC    double    atof();
  674.     XPUBLIC    char    *index();
  675.     X
  676.     XPUBLIC    Canvas    display;
  677.     XPUBLIC    Panel    keys;
  678.     XPUBLIC    struct    pixfont    *key_font;
  679.     X
  680.     XPRIVATE    Pixwin    *pw = NULL;
  681.     XPRIVATE    struct    pixfont    *d_font = NULL;
  682.     XPRIVATE    struct    pixfont    *s_font = NULL;
  683.     XPRIVATE    char    e_str[5], d_str[18];
  684.     XPRIVATE    int    e_len = 0;
  685.     XPRIVATE    int    d_len = 0;
  686.     XPRIVATE    int    pw_width;
  687.     XPRIVATE    int    pw_height;
  688.     XPRIVATE    char    *digit = "0123456789ABCDEF.E-";
  689.     X
  690.     XPRIVATE    verify(source, valid)
  691.     X
  692.     Xchar    *source;
  693.     Xchar    *valid;
  694.     X
  695.     X{    register    char    *s;
  696.     X
  697.     X    for ( ; *source; source++) {
  698.     X       for (s = valid; *s && *s != *source; s++)
  699.     X          ;
  700.     X       if (*s == '\0')
  701.     X          return(FALSE);
  702.     X       }
  703.     X    return(TRUE);
  704.     X}
  705.     X
  706.     XPRIVATE    convert_stacktop()
  707.     X
  708.     X{    char    buf[60], *p;
  709.     X
  710.     X    convert_value(v_stack[v_top], buf);
  711.     X    if (curr_mode == SCIENTIFIC && (p = index(buf, 'E')) != NULL) {
  712.     X       strcpy(e_str, p + 1);
  713.     X       if (*e_str == '+')
  714.     X          strcpy(e_str, e_str + 1);
  715.     X       e_len = strlen(e_str);
  716.     X       if (e_len == 2) {
  717.     X          e_str[3] = '\0';
  718.     X          e_str[2] = e_str[1];
  719.     X          e_str[1] = e_str[0];
  720.     X          e_str[0] = '0';
  721.     X          e_len = 3;
  722.     X          }
  723.     X       else if (e_len == 3 && *e_str == '-') {
  724.     X          e_str[4] = '\0';
  725.     X          e_str[3] = e_str[2];
  726.     X          e_str[2] = e_str[1];
  727.     X          e_str[1] = '0';
  728.     X          e_len = 4;
  729.     X          }
  730.     X       *p = '\0';
  731.     X       }
  732.     X    else {
  733.     X       *e_str = '\0';
  734.     X       e_len = 0;
  735.     X       }
  736.     X    strcpy(d_str, buf);
  737.     X    d_len = strlen(d_str);
  738.     X}
  739.     X
  740.     XPUBLIC    update_display()
  741.     X
  742.     X{    char    buf[60], *p, *op_str();
  743.     X    int    i, w;
  744.     X    static    char    *tm[] = {"Deg ", "Rad ", "Grad"};
  745.     X
  746.     X    if (d_font == NULL)
  747.     X       if ((d_font = pf_open(DIGIT_FONT)) == NULL) {
  748.     X          fprintf(stderr, "calctool: could not open font %s\n", DIGIT_FONT);
  749.     X          exit(1);
  750.     X          }
  751.     X    if (s_font == NULL)
  752.     X       if ((s_font = pf_open(STATUS_FONT)) == NULL) {
  753.     X          fprintf(stderr, "calctool: could not open font %s\n", DIGIT_FONT);
  754.     X          exit(1);
  755.     X          }
  756.     X    if (pw == NULL) {
  757.     X       pw = canvas_pixwin(display);
  758.     X       pw_width = (int) window_get(display, WIN_WIDTH);
  759.     X       pw_height = (int) window_get(display, WIN_HEIGHT);
  760.     X       }
  761.     X    for (i = w = 0; i < o_top && w < 23; w += strlen(op_str(o_stack[i++])))
  762.     X       pw_text(pw, w * STATUS_WIDTH + 1, 7, PIX_SRC, s_font, op_str(o_stack[i]));
  763.     X    for ( ; w < 23; w++)
  764.     X       pw_text(pw, w * STATUS_WIDTH + 1, 7, PIX_SRC, s_font, " ");
  765.     X    pw_text(pw, 23 * STATUS_WIDTH, 7, PIX_SRC, s_font, (curr_mode == SCIENTIFIC)? tm[trig_mode] : "    ");
  766.     X    if (curr_mode == SCIENTIFIC && ee_mode)
  767.     X       pw_text(pw, 28 * STATUS_WIDTH, 7, PIX_SRC, s_font, eng_mode? "Eng " : "EE  ");
  768.     X    else
  769.     X       pw_text(pw, 28 * STATUS_WIDTH, 7, PIX_SRC, s_font, "    ");
  770.     X    if (curr_mode == SCIENTIFIC)
  771.     X       if (curr_width[0] == -1)
  772.     X          strcpy(buf, "    Float");
  773.     X       else
  774.     X          sprintf(buf, "%2d Digits", curr_width[0]);
  775.     X    else
  776.     X       sprintf(buf, "  %2d Bits", curr_width[index_of(curr_base)]);
  777.     X    pw_text(pw, 32 * STATUS_WIDTH, 7, PIX_SRC, s_font, buf);
  778.     X    if (d_len > 0) {
  779.     X       if (e_len > 0) {
  780.     X          pw_text(pw, pw_width - 6 * DIGIT_WIDTH, 26, PIX_SRC, d_font, " e");
  781.     X          pw_text(pw, pw_width - 4 * DIGIT_WIDTH, 26, PIX_SRC, d_font, e_str);
  782.     X          if (e_len == 3)
  783.     X             pw_text(pw, pw_width - DIGIT_WIDTH, 26, PIX_SRC, d_font, " ");
  784.     X          }
  785.     X       else
  786.     X          pw_text(pw, pw_width - 6 * DIGIT_WIDTH, 26, PIX_SRC, d_font, "      ");
  787.     X       pw_rop(pw, 0, pw_height - DIGIT_HEIGHT + 1, margin(d_str), DIGIT_HEIGHT, PIX_SRC | PIX_COLOR(0), NULL, 0, 0);
  788.     X       pw_text(pw, margin(d_str), 26, PIX_SRC, d_font, d_str);
  789.     X       }
  790.     X    else {
  791.     X       convert_value(v_stack[v_top], buf);
  792.     X       if (strcmp(buf, "NaN") == 0) {
  793.     X          strcpy(buf, "       Error!   ");
  794.     X          pw_text(pw, pw_width - 6 * DIGIT_WIDTH, 26, PIX_SRC, d_font, "      ");
  795.     X          }
  796.     X       else if (curr_mode == SCIENTIFIC && (p = index(buf, 'E')) != NULL) {
  797.     X          pw_text(pw, pw_width - 6 * DIGIT_WIDTH, 26, PIX_SRC, d_font, " e");
  798.     X          *p++ = '\0';
  799.     X          i = 4;
  800.     X          if (*p == '+')
  801.     X             p++;
  802.     X          if (*p == '-') {
  803.     X             pw_text(pw, pw_width - i-- * DIGIT_WIDTH, 26, PIX_SRC, d_font, "-");
  804.     X             p++;
  805.     X             }
  806.     X          if (strlen(p) == 2)
  807.     X             pw_text(pw, pw_width - i-- * DIGIT_WIDTH, 26, PIX_SRC, d_font, "0");
  808.     X          pw_text(pw, pw_width - i * DIGIT_WIDTH, 26, PIX_SRC, d_font, p);
  809.     X          if (i - strlen(p) == 1)
  810.     X            pw_text(pw, pw_width - DIGIT_WIDTH, 26, PIX_SRC, d_font, " ");
  811.     X          }
  812.     X       else
  813.     X          pw_text(pw, pw_width - 6 * DIGIT_WIDTH, 26, PIX_SRC, d_font, "      ");
  814.     X       pw_rop(pw, 0, pw_height - DIGIT_HEIGHT + 1, margin(buf), DIGIT_HEIGHT, PIX_SRC|PIX_COLOR(0), NULL, 0, 0);
  815.     X       pw_text(pw, margin(buf), 26, PIX_SRC, d_font, buf);
  816.     X       }
  817.     X}
  818.     X
  819.     XPUBLIC    convert_display()
  820.     X
  821.     X{    char    buf[60], *p;
  822.     X    int    i;
  823.     X
  824.     X    if (d_len > 0 || e_len > 0)
  825.     X       if (curr_mode == SCIENTIFIC) {
  826.     X          strcpy(buf, d_str);
  827.     X          strcat(buf, "E");
  828.     X          strcat(buf, e_str);
  829.     X          v_stack[v_top] = atof(buf);
  830.     X          }
  831.     X       else {
  832.     X          for (i = 0, p = d_str; *p; p++)
  833.     X             i = i * curr_base + (index(digit, *p) - digit);
  834.     X          v_stack[v_top] = (double) i;
  835.     X          }
  836.     X    edit_ee = FALSE;
  837.     X    clear_entry();
  838.     X}
  839.     X
  840.     XPUBLIC    convert_value(val, s)
  841.     X
  842.     Xdouble    val;
  843.     Xchar    *s;
  844.     X
  845.     X{    unsigned    int    i;
  846.     X    int    start, exp, dp, sign = 1, j, sp;
  847.     X    char    *p, *q, buf[60];
  848.     X
  849.     X    if (curr_mode == SCIENTIFIC) {
  850.     X       sprintf(s, "                              %-20.15E", val);
  851.     X       if (!verify(s, " 0123456789eE+-.")) {
  852.     X          strcpy(s, "NaN");
  853.     X          return;
  854.     X          }
  855.     X       if (s[30] == '-') {
  856.     X          sign = -1;
  857.     X          strcpy(&(s[30]), &(s[31]));
  858.     X          }
  859.     X       start = 30;
  860.     X       sscanf(&(s[start + 18]), "%d", &exp);
  861.     X       s[start + 17] = '\0';
  862.     X       strcpy(&(s[start + 1]), &(s[start + 2])); /* lose the decimal point */
  863.     X       exp++; /* and remember it */
  864.     X       if (s[start + 13] >= '5') /* round up */
  865.     X          for (i = start + 12; ; i--) {
  866.     X             s[i]++;
  867.     X             if (s[i] == ':') {
  868.     X                s[i] = '0';
  869.     X                if (i == start) {
  870.     X                   s[--start] = '1';
  871.     X                   exp++;
  872.     X                   break;
  873.     X                   }
  874.     X                }
  875.     X             else
  876.     X                break;
  877.     X             }
  878.     X       s[start + 13] = '\0'; /* retain 13 digits */
  879.     X       s[start - 1] = s[start];
  880.     X       s[start--] = '.';
  881.     X       exp--;
  882.     X       dp = start + 1;
  883.     X       if (ee_mode || exp > 12 || exp < ((curr_width[0] == -1)? -12 : -curr_width[0])) {
  884.     X          if (eng_mode)
  885.     X             for ( ; exp % 3; dp++, exp--) {
  886.     X                s[dp] = s[dp + 1];
  887.     X                s[dp + 1] = '.';
  888.     X                }
  889.     X          if (curr_width[0] != -1) {
  890.     X             i = strlen(s + dp + 1);
  891.     X             if (i > curr_width[0])
  892.     X                s[dp + curr_width[0] + 1] = '\0';
  893.     X             }
  894.     X          else
  895.     X             for (i = strlen(s) - 1; s[i] == '0'; s[i--] = '\0')
  896.     X                ;
  897.     X          if (s[i = strlen(s) - 1] == '.')
  898.     X             s[i] = '\0';
  899.     X          sprintf(s + strlen(s), "E%03d", exp);
  900.     X          }
  901.     X       else {
  902.     X          for ( ; exp > 0; dp++, exp--) {
  903.     X             s[dp] = s[dp + 1];
  904.     X             s[dp + 1] = '.';
  905.     X             }
  906.     X          for ( ; exp < 0; dp--, exp++) {
  907.     X             s[dp] = s[dp - 1];
  908.     X             s[dp - 1] = '.';
  909.     X             s[dp - 2] = '0';
  910.     X             start = dp - 2;
  911.     X             }
  912.     X          if (curr_width[0] != -1) {
  913.     X             i = strlen(s + dp + 1);
  914.     X             if (i > curr_width[0])
  915.     X                s[dp + curr_width[0] + 1] = '\0';
  916.     X             else
  917.     X                for ( ; i < curr_width[0]; i++)
  918.     X                   strcat(s, "0");
  919.     X             if (strlen(s + start) > 14)
  920.     X                s[start + 14] = '\0';
  921.     X             }
  922.     X          else {
  923.     X             for (i = strlen(s) - 1; s[i] == '0'; s[i--] = '\0');
  924.     X             if (strlen(s + dp + 1) > 12)
  925.     X                s[dp + 13] = '\0';
  926.     X             if (s[i = strlen(s) - 1] == '.')
  927.     X                s[i] = '\0';
  928.     X             }
  929.     X          }
  930.     X       if (sign == -1)
  931.     X          s[--start] = '-';
  932.     X       strcpy(s, s + start);
  933.     X       }
  934.     X    else {
  935.     X       i = (unsigned int) val;
  936.     X       i &= ((unsigned) 0xffffffff) >> (32 - curr_width[index_of(curr_base)]);
  937.     X       for (p = buf; i; i = i >> index_of(curr_base))
  938.     X          *p++ = digit[i & (curr_base - 1)];
  939.     X       *p = '\0';
  940.     X       if (*buf == '\0')
  941.     X          strcpy(buf, "0");
  942.     X       for (j = strlen(buf) - 1, p = s; j >= 0; j--, p++)
  943.     X          *p = buf[j];
  944.     X       *p = '\0';
  945.     X       }
  946.     X}
  947.     X
  948.     X
  949.     XPUBLIC    fix_proc(item, event)
  950.     X
  951.     XPanel_item    item;
  952.     XEvent        *event;
  953.     X
  954.     X{    static    Menu    s_menu = NULL;
  955.     X    static    Menu    b_menu = NULL;
  956.     X    static    Menu    h_menu = NULL;
  957.     X    static    Menu    t_menu = NULL;
  958.     X    int    i;
  959.     X
  960.     X    if (event_id(event) >= ASCII_FIRST && event_id(event) <= ASCII_LAST) {
  961.     X       keyboard(event_id(event));
  962.     X       return;
  963.     X       }
  964.     X    if ((event_id(event) == MS_LEFT && !inverted) || (event_id(event) == MS_MIDDLE && inverted))
  965.     X       if (curr_mode == SCIENTIFIC)
  966.     X          if (curr_width[0] == 12)
  967.     X             curr_width[0] = -1;
  968.     X          else
  969.     X             curr_width[0]++;
  970.     X       else
  971.     X          switch (curr_base) {
  972.     X             case BINARY      : if (curr_width[1] == 16)
  973.     X                            curr_width[1] = 4;
  974.     X                             else
  975.     X                                curr_width[1] *= 2;
  976.     X                             break;
  977.     X             case OCTAL       : 
  978.     X             case HEXADECIMAL : if (curr_width[index_of(curr_base)] == 32)
  979.     X                            curr_width[index_of(curr_base)] = 8;
  980.     X                             else
  981.     X                                curr_width[index_of(curr_base)] *= 2;
  982.     X                             break;
  983.     X             }
  984.     X    else if (curr_mode == SCIENTIFIC && ((event_id(event) == MS_LEFT && inverted) || (event_id(event) == MS_MIDDLE && !inverted)))
  985.     X       if (trig_mode == GRAD)
  986.     X          trig_mode = DEG;
  987.     X       else
  988.     X          trig_mode++;
  989.     X    else if (event_id(event) == MS_RIGHT) {
  990.     X       if (inverted) {
  991.     X          if (t_menu == NULL)
  992.     X             t_menu = menu_create(MENU_INITIAL_SELECTION, MENU_DEFAULT,
  993.     X                           MENU_ITEM, MENU_STRING, "Degrees", MENU_VALUE, 1, MENU_FONT, key_font, 0,
  994.     X                           MENU_ITEM, MENU_STRING, "Radians", MENU_VALUE, 2, MENU_FONT, key_font, 0,
  995.     X                           MENU_ITEM, MENU_STRING, "Grads",   MENU_VALUE, 3, MENU_FONT, key_font, 0,
  996.     X                           0);
  997.     X          menu_set(t_menu, MENU_DEFAULT, trig_mode + 1, 0);
  998.     X          if ((i = (int) menu_show(t_menu, keys, event, 0)) != 0)
  999.     X             trig_mode = i - 1;
  1000.     X          }
  1001.     X       else if (curr_mode == SCIENTIFIC) {
  1002.     X          if (s_menu == NULL)
  1003.     X             s_menu = menu_create(MENU_INITIAL_SELECTION, MENU_DEFAULT,
  1004.     X                           MENU_ITEM, MENU_STRING, "   Float",  MENU_VALUE,  1, MENU_FONT, key_font, 0,
  1005.     X                           MENU_ITEM, MENU_STRING, " 0 Digits", MENU_VALUE,  2, MENU_FONT, key_font, 0,
  1006.     X                           MENU_ITEM, MENU_STRING, " 1 Digit",  MENU_VALUE,  3, MENU_FONT, key_font, 0,
  1007.     X                           MENU_ITEM, MENU_STRING, " 2 Digits", MENU_VALUE,  4, MENU_FONT, key_font, 0,
  1008.     X                           MENU_ITEM, MENU_STRING, " 3 Digits", MENU_VALUE,  5, MENU_FONT, key_font, 0,
  1009.     X                           MENU_ITEM, MENU_STRING, " 4 Digits", MENU_VALUE,  6, MENU_FONT, key_font, 0,
  1010.     X                           MENU_ITEM, MENU_STRING, " 5 Digits", MENU_VALUE,  7, MENU_FONT, key_font, 0,
  1011.     X                           MENU_ITEM, MENU_STRING, " 6 Digits", MENU_VALUE,  8, MENU_FONT, key_font, 0,
  1012.     X                           MENU_ITEM, MENU_STRING, " 7 Digits", MENU_VALUE,  9, MENU_FONT, key_font, 0,
  1013.     X                           MENU_ITEM, MENU_STRING, " 8 Digits", MENU_VALUE, 10, MENU_FONT, key_font, 0,
  1014.     X                           MENU_ITEM, MENU_STRING, " 9 Digits", MENU_VALUE, 11, MENU_FONT, key_font, 0,
  1015.     X                           MENU_ITEM, MENU_STRING, "10 Digits", MENU_VALUE, 12, MENU_FONT, key_font, 0,
  1016.     X                           MENU_ITEM, MENU_STRING, "11 Digits", MENU_VALUE, 13, MENU_FONT, key_font, 0,
  1017.     X                           MENU_ITEM, MENU_STRING, "12 Digits", MENU_VALUE, 14, MENU_FONT, key_font, 0,
  1018.     X                           0);
  1019.     X          menu_set(s_menu, MENU_DEFAULT, curr_width[0] + 2, 0);
  1020.     X          if ((i = (int) menu_show(s_menu, keys, event, 0)) != 0)
  1021.     X             curr_width[0] = i - 2;
  1022.     X          }
  1023.     X       else if (curr_base == BINARY) {
  1024.     X          if (b_menu == NULL)
  1025.     X             b_menu = menu_create(MENU_INITIAL_SELECTION, MENU_DEFAULT,
  1026.     X                           MENU_ITEM, MENU_STRING, " 4 Bits", MENU_VALUE,  4, MENU_FONT, key_font, 0,
  1027.     X                           MENU_ITEM, MENU_STRING, " 8 Bits", MENU_VALUE,  8, MENU_FONT, key_font, 0,
  1028.     X                           MENU_ITEM, MENU_STRING, "16 Bits", MENU_VALUE, 16, MENU_FONT, key_font, 0,
  1029.     X                           0);
  1030.     X          menu_set(b_menu, MENU_DEFAULT_ITEM, menu_find(b_menu, MENU_VALUE, curr_width[1], 0), 0);
  1031.     X          if ((i = (int) menu_show(b_menu, keys, event, 0)) != 0)
  1032.     X             curr_width[1] = i;
  1033.     X          }
  1034.     X       else {
  1035.     X          if (h_menu == NULL)
  1036.     X             h_menu = menu_create(MENU_INITIAL_SELECTION, MENU_DEFAULT,
  1037.     X                           MENU_ITEM, MENU_STRING, " 8 Bits", MENU_VALUE,  8, MENU_FONT, key_font, 0,
  1038.     X                           MENU_ITEM, MENU_STRING, "16 Bits", MENU_VALUE, 16, MENU_FONT, key_font, 0,
  1039.     X                           MENU_ITEM, MENU_STRING, "32 Bits", MENU_VALUE, 32, MENU_FONT, key_font, 0,
  1040.     X                           0);
  1041.     X          menu_set(h_menu, MENU_DEFAULT_ITEM, menu_find(h_menu, MENU_VALUE, curr_width[index_of(curr_base)], 0), 0);
  1042.     X          if ((i = (int) menu_show(h_menu, keys, event, 0)) != 0)
  1043.     X             curr_width[index_of(curr_base)] = i;
  1044.     X          }
  1045.     X       }
  1046.     X    convert_display();
  1047.     X    update_display();
  1048.     X    if (inverted)
  1049.     X       invert_proc();
  1050.     X}
  1051.     X
  1052.     Xdo_digit(op)
  1053.     X
  1054.     Xint    op;
  1055.     X
  1056.     X{    char    temp[60];
  1057.     X
  1058.     X    if (op <= DIGIT_F) {
  1059.     X       if (edit_ee && e_len > 0) {
  1060.     X          e_str[e_len - 3] = e_str[e_len - 2];
  1061.     X          e_str[e_len - 2] = e_str[e_len - 1];
  1062.     X          e_str[e_len - 1] = digit[op];
  1063.     X          }
  1064.     X       else if (d_len == 1 && d_str[0] == '0')
  1065.     X          d_str[0] = digit[op];
  1066.     X       else if (d_len < MAX_DIGITS) {
  1067.     X          d_str[d_len] = digit[op];
  1068.     X          d_str[++d_len] = '\0';
  1069.     X          }
  1070.     X       }
  1071.     X    else if (op == DIGIT_DOT) {
  1072.     X       if (e_len == 0 && index(d_str, '.') == 0) {
  1073.     X          if (d_len == 0) {
  1074.     X             strcpy(d_str, "0.");
  1075.     X             d_len = 2;
  1076.     X             }
  1077.     X          else {
  1078.     X             d_str[d_len] = '.';
  1079.     X             d_str[++d_len] = '\0';
  1080.     X             }
  1081.     X          }
  1082.     X       }
  1083.     X    else if (op == DIGIT_CHS) {
  1084.     X       if (edit_ee && e_len > 0)
  1085.     X          if (e_len == 4) {
  1086.     X             strcpy(e_str, e_str + 1);
  1087.     X             e_len = 3;
  1088.     X             }
  1089.     X          else {
  1090.     X             e_str[3] = e_str[2];
  1091.     X             e_str[2] = e_str[1];
  1092.     X             e_str[1] = e_str[0];
  1093.     X             e_str[0] = '-';
  1094.     X             e_len = 4;
  1095.     X             }
  1096.     X       else {
  1097.     X          if (d_len == 0)
  1098.     X             convert_stacktop();
  1099.     X          if (curr_mode == SCIENTIFIC) {
  1100.     X             if (d_len > 0 && strcmp(d_str, "0") != 0)
  1101.     X                if (d_str[0] == '-') {
  1102.     X                   strcpy(d_str, d_str + 1);
  1103.     X                   d_len -= 1;
  1104.     X                   }
  1105.     X                else {
  1106.     X                   strcpy(temp, d_str);
  1107.     X                   d_str[0] = '-';
  1108.     X                   strcpy(d_str + 1, temp);
  1109.     X                   d_len += 1;
  1110.     X                   }
  1111.     X             }
  1112.     X          else {
  1113.     X             convert_display();
  1114.     X             v_stack[v_top] = -v_stack[v_top];
  1115.     X             convert_stacktop();
  1116.     X             }
  1117.     X          }
  1118.     X       }
  1119.     X    else if (op == DIGIT_EE) {
  1120.     X       ee_mode = TRUE;
  1121.     X       edit_ee = !edit_ee;
  1122.     X       if (d_len == 0)
  1123.     X          convert_stacktop();
  1124.     X       if (e_len == 0) {
  1125.     X          e_len = 3;
  1126.     X          strcpy(e_str, "000");
  1127.     X          }
  1128.     X       }
  1129.     X    update_display();
  1130.     X}
  1131.     X
  1132.     XPUBLIC    clear_entry()
  1133.     X
  1134.     X{
  1135.     X    e_str[e_len = 0] = d_str[d_len = 0] = '\0';
  1136.     X    edit_ee = FALSE;
  1137.     X}
  1138.     X
  1139.     XPUBLIC    keyboard(key)
  1140.     X
  1141.     Xchar    key;
  1142.     X
  1143.     X{    double    temp;
  1144.     X
  1145.     X    switch (key) {
  1146.     X       case '0' : 
  1147.     X       case '1' : 
  1148.     X       case '2' : 
  1149.     X       case '3' : 
  1150.     X       case '4' : 
  1151.     X       case '5' : 
  1152.     X       case '6' : 
  1153.     X       case '7' : 
  1154.     X       case '8' : 
  1155.     X       case '9' : if (curr_mode == SCIENTIFIC || (key - '0' + DIGIT_0 < curr_base))
  1156.     X                do_digit(blink(key - '0' + DIGIT_0));
  1157.     X                 break;
  1158.     X       case 'A' : 
  1159.     X       case 'B' : 
  1160.     X       case 'C' : 
  1161.     X       case 'D' : 
  1162.     X       case 'F' : if (curr_mode == PROGRAMMER && curr_base == HEXADECIMAL)
  1163.     X               do_digit(blink(key - 'A' + DIGIT_A));
  1164.     X                 break;
  1165.     X       case 'a' : 
  1166.     X       case 'b' : 
  1167.     X       case 'c' : 
  1168.     X       case 'd' : 
  1169.     X       case 'f' : if (curr_mode == PROGRAMMER && curr_base == HEXADECIMAL)
  1170.     X                do_digit(blink(key - 'a' + DIGIT_A));
  1171.     X                 break;
  1172.     X       case 'e' :
  1173.     X       case 'E' : if (curr_mode == PROGRAMMER && curr_base == HEXADECIMAL)
  1174.     X                do_digit(blink(DIGIT_E));
  1175.     X                 else if (curr_mode == SCIENTIFIC)
  1176.     X                    do_digit(blink(DIGIT_EE));
  1177.     X                 break;
  1178.     X       case 'g' :
  1179.     X       case 'G' : blink(EXC_OP);
  1180.     X                 convert_display();
  1181.     X                 do_exchange(0);
  1182.     X                 break;
  1183.     X       case 'r' :
  1184.     X       case 'R' : blink(RCL_OP);
  1185.     X                 clear_entry();
  1186.     X                 do_recall(0);
  1187.     X                 break;
  1188.     X       case 's' :
  1189.     X       case 'S' : blink(STO_OP);
  1190.     X                 convert_display();
  1191.     X                 do_store(0);
  1192.     X                 break;
  1193.     X       case '.' : if (curr_mode == SCIENTIFIC)
  1194.     X                do_digit(blink(DIGIT_DOT));
  1195.     X                 break;
  1196.     X       case '+' : do_binary(blink(ADD_OP));
  1197.     X                 break;
  1198.     X       case '-' : do_binary(blink(SUB_OP));
  1199.     X                 break;
  1200.     X       case 'x' :
  1201.     X       case 'X' :
  1202.     X       case '*' : do_binary(blink(MUL_OP));
  1203.     X                 break;
  1204.     X       case '/' : do_binary(blink(DIV_OP));
  1205.     X                 break;
  1206.     X       case '&' : if (curr_mode == PROGRAMMER)
  1207.     X                do_binary(blink(AND_OP));
  1208.     X                 break;
  1209.     X       case '|' : if (curr_mode == PROGRAMMER)
  1210.     X                do_binary(blink(OR_OP));
  1211.     X                 break;
  1212.     X       case '^' : if (curr_mode == PROGRAMMER)
  1213.     X                do_binary(blink(XOR_OP));
  1214.     X                 break;
  1215.     X       case '\n':
  1216.     X       case '\r':
  1217.     X       case '=' : do_unary(blink(EQUAL_OP));
  1218.     X                 break;
  1219.     X       case '(' : do_unary(blink(LPAREN_OP));
  1220.     X                 break;
  1221.     X       case ')' : do_unary(blink(RPAREN_OP));
  1222.     X                 break;
  1223.     X       }
  1224.     X}
  1225.     X
  1226. SHAR_EOF
  1227. if test 19031 -ne "`wc -c < 'display.c'`"
  1228. then
  1229.     echo shar: error transmitting "'display.c'" '(should have been 19031 characters)'
  1230. fi
  1231. fi # end of overwriting check
  1232. echo shar: extracting "'globals.c'" '(1651 characters)'
  1233. if test -f 'globals.c'
  1234. then
  1235.     echo shar: will not over-write existing file "'globals.c'"
  1236. else
  1237. sed 's/^    X//' << \SHAR_EOF > 'globals.c'
  1238.     X/************************************************************************/
  1239.     X/*    Copyright 1988 by Chuck Musciano and Harris Corporation        */
  1240.     X/*                                    */
  1241.     X/*    Permission to use, copy, modify, and distribute this software    */
  1242.     X/*    and its documentation for any purpose and without fee is    */
  1243.     X/*    hereby granted, provided that the above copyright notice    */
  1244.     X/*    appear in all copies and that both that copyright notice and    */
  1245.     X/*    this permission notice appear in supporting documentation, and    */
  1246.     X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  1247.     X/*    used in advertising or publicity pertaining to distribution    */
  1248.     X/*    of the software without specific, written prior permission.    */
  1249.     X/*    Chuck Musciano and Harris Corporation make no representations    */
  1250.     X/*    about the suitability of this software for any purpose.  It is    */
  1251.     X/*    provided "as is" without express or implied warranty.        */
  1252.     X/************************************************************************/
  1253.     X
  1254.     X/************************************************************************/
  1255.     X/*                                    */
  1256.     X/*    Module:        globals.c                    */
  1257.     X/*                                    */
  1258.     X/*    Function:    Define global variables                */
  1259.     X/*                                    */
  1260.     X/*    Change History:    14 Nov 86    Creation            */
  1261.     X/*                                    */
  1262.     X/************************************************************************/
  1263.     X
  1264.     X#include    "manifest.h"
  1265.     X#include    "globals.h"
  1266.     X
  1267.     Xint    curr_mode    = SCIENTIFIC;
  1268.     Xint    inverted    = FALSE;
  1269.     Xint    temp_inverted    = FALSE;
  1270.     X
  1271.     Xint    curr_base    = DECIMAL;
  1272.     Xint    ee_mode        = FALSE;
  1273.     Xint    eng_mode    = FALSE;
  1274.     Xint    edit_ee        = FALSE;
  1275.     Xint    trig_mode    = DEG;
  1276.     Xint    curr_width[5]    = {-1, 16, 0, 32, 32};
  1277.     X
  1278.     Xdouble    v_stack[MAX_STACK] = {0.0};
  1279.     Xint    o_stack[MAX_STACK] = {0};
  1280.     Xint    v_top        = 0;
  1281.     Xint    o_top        = 0;
  1282. SHAR_EOF
  1283. if test 1651 -ne "`wc -c < 'globals.c'`"
  1284. then
  1285.     echo shar: error transmitting "'globals.c'" '(should have been 1651 characters)'
  1286. fi
  1287. fi # end of overwriting check
  1288. echo shar: extracting "'globals.h'" '(1581 characters)'
  1289. if test -f 'globals.h'
  1290. then
  1291.     echo shar: will not over-write existing file "'globals.h'"
  1292. else
  1293. sed 's/^    X//' << \SHAR_EOF > 'globals.h'
  1294.     X/************************************************************************/
  1295.     X/*    Copyright 1988 by Chuck Musciano and Harris Corporation        */
  1296.     X/*                                    */
  1297.     X/*    Permission to use, copy, modify, and distribute this software    */
  1298.     X/*    and its documentation for any purpose and without fee is    */
  1299.     X/*    hereby granted, provided that the above copyright notice    */
  1300.     X/*    appear in all copies and that both that copyright notice and    */
  1301.     X/*    this permission notice appear in supporting documentation, and    */
  1302.     X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  1303.     X/*    used in advertising or publicity pertaining to distribution    */
  1304.     X/*    of the software without specific, written prior permission.    */
  1305.     X/*    Chuck Musciano and Harris Corporation make no representations    */
  1306.     X/*    about the suitability of this software for any purpose.  It is    */
  1307.     X/*    provided "as is" without express or implied warranty.        */
  1308.     X/************************************************************************/
  1309.     X
  1310.     X/************************************************************************/
  1311.     X/*                                    */
  1312.     X/*    Module:        globals.h                    */
  1313.     X/*                                    */
  1314.     X/*    Function:    Define global variables                */
  1315.     X/*                                    */
  1316.     X/*    Change History:    14 Nov 86    Creation            */
  1317.     X/*                                    */
  1318.     X/************************************************************************/
  1319.     X
  1320.     XPUBLIC    int    curr_mode;
  1321.     XPUBLIC    int    inverted;
  1322.     XPUBLIC    int    temp_inverted;
  1323.     X
  1324.     XPUBLIC    int    curr_base;
  1325.     XPUBLIC    int    ee_mode;
  1326.     XPUBLIC    int    eng_mode;
  1327.     XPUBLIC    int    edit_ee;
  1328.     XPUBLIC    int    trig_mode;
  1329.     XPUBLIC    int    curr_width[5];
  1330.     X
  1331.     XPUBLIC    double    v_stack[MAX_STACK];
  1332.     XPUBLIC    int    o_stack[MAX_STACK];
  1333.     XPUBLIC    int    v_top;
  1334.     XPUBLIC    int    o_top;
  1335. SHAR_EOF
  1336. if test 1581 -ne "`wc -c < 'globals.h'`"
  1337. then
  1338.     echo shar: error transmitting "'globals.h'" '(should have been 1581 characters)'
  1339. fi
  1340. fi # end of overwriting check
  1341. #    End of shell archive
  1342. exit 0
  1343.